<!DOCTYPE html>
<html >
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="张树淼" />



<meta name="description" content="使用base64形式上传文件">
<meta name="keywords" content="上传文件">
<meta property="og:type" content="article">
<meta property="og:title" content="使用base64形式上传文件">
<meta property="og:url" content="http://yoursite.com/2019/12/17/使用base64形式上传文件/index.html">
<meta property="og:site_name" content="Sapling">
<meta property="og:description" content="使用base64形式上传文件">
<meta property="og:locale" content="default">
<meta property="og:image" content="http://yoursite.com/2019/12/17/使用base64形式上传文件/base64.png">
<meta property="og:updated_time" content="2019-12-17T03:12:46.531Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="使用base64形式上传文件">
<meta name="twitter:description" content="使用base64形式上传文件">
<meta name="twitter:image" content="http://yoursite.com/2019/12/17/使用base64形式上传文件/base64.png">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="Sapling" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>使用base64形式上传文件 | Sapling</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script> yiliaConfig.jquery_ui = [false]; </script>



    <script> yiliaConfig.rootUrl = "\/";</script>






</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar1.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">张树淼</a></h1>
        </hgroup>

        
        <p class="header-subtitle">生活没有奇迹, 只有轨迹 !</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="false" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/tags/">标签云</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:123@123.com" title="Email"></a>
                            
                                <a class="fa GitHub" href="https://github.com/shumiaozhang" title="GitHub"></a>
                            
                                <a class="fa RSS" href="/atom.xml" title="RSS"></a>
                            
                                <a class="fa CSDN" href="https://blog.csdn.net/zsm4623" title="CSDN"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Web-API/">Web API</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jQuery教程/">jQuery教程</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/上传文件/">上传文件</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/跨域/">跨域</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">专注于前端</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">张树淼</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar1.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">张树淼</a></h1>
            </hgroup>
            
            <p class="header-subtitle">生活没有奇迹, 只有轨迹 !</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/tags/">标签云</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:123@123.com" title="Email"></a>
                            
                                <a class="fa GitHub" target="_blank" href="https://github.com/shumiaozhang" title="GitHub"></a>
                            
                                <a class="fa RSS" target="_blank" href="/atom.xml" title="RSS"></a>
                            
                                <a class="fa CSDN" target="_blank" href="https://blog.csdn.net/zsm4623" title="CSDN"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我"/>
</nav>
      <div class="body-wrap"><article id="post-使用base64形式上传文件" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2019/12/17/使用base64形式上传文件/" class="article-date">
      <time datetime="2019-12-17T02:17:47.000Z" itemprop="datePublished">2019-12-17</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      使用base64形式上传文件
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        

        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/上传文件/">上传文件</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"file"</span> <span class="attr">id</span>=<span class="string">"fielinput"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">id</span>=<span class="string">"txshow"</span> <span class="attr">style</span>=<span class="string">"width:100px;height:100px;"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span>/&gt;</span>解析之后的base64数据：<span class="tag">&lt;<span class="name">br</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span> <span class="attr">id</span>=<span class="string">"data"</span>&gt;</span><span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/***</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * FileReader 对象允许Web应用程序异步读取存储在用户计算机上的文件（或原始数据缓冲区）的内容，</span></span><br><span class="line"><span class="comment"> * 使用 File 或 Blob 对象指定要读取的文件或数据。</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    其中File对象可以是来自用户在一个&lt;input&gt;元素上选择文件后返回的FileList对象,</span></span><br><span class="line"><span class="comment">    也可以来自拖放操作生成的 DataTransfer对象,还可以是来自在一个HTMLCanvasElement上执行mozGetAsFile()方法后返回结果</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * FileReader() 构造函数</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * 属性</span></span><br><span class="line"><span class="comment"> *      FeileReader.error只读，表示读取文件失败时发生的错误</span></span><br><span class="line"><span class="comment"> *      FeileReader.readyState只读，readyState代表数字，状态</span></span><br><span class="line"><span class="comment"> *         EMPTY =&gt; 0 =&gt; 还未加载任何数据  </span></span><br><span class="line"><span class="comment"> *         LOADINF =&gt; 1 =&gt; 正在加载</span></span><br><span class="line"><span class="comment"> *         DONE =&gt; 2 =&gt; 已经全部读取完成</span></span><br><span class="line"><span class="comment"> *      FeileReader.result只读，</span></span><br><span class="line"><span class="comment"> *          文件的内容，这个属性要在读取完成(也就是readyState变为2时)后才有效。</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * 事件处理事件</span></span><br><span class="line"><span class="comment"> *      FeileReader.onabort </span></span><br><span class="line"><span class="comment"> *          处理abort事件，在读取操作中如果要中断(终止)执行的事件</span></span><br><span class="line"><span class="comment"> *      FeileReader.error</span></span><br><span class="line"><span class="comment"> *          在读取时如果发生错误时会触发</span></span><br><span class="line"><span class="comment"> *      FeileReader.onload</span></span><br><span class="line"><span class="comment"> *          处理load事件，在读取操作完成时触发的(成功时若有提示框弹出成功等字样，写在这里)</span></span><br><span class="line"><span class="comment"> *          FeileReader.onload = function()&#123;&#125;</span></span><br><span class="line"><span class="comment"> *      FeileReader.onloadStart </span></span><br><span class="line"><span class="comment"> *          在开始读取的时候触发</span></span><br><span class="line"><span class="comment"> *      FeileReader.onloadEnd</span></span><br><span class="line"><span class="comment"> *          在读取操作结束的时候触发</span></span><br><span class="line"><span class="comment"> *      FeileReader.onProgess</span></span><br><span class="line"><span class="comment"> *          该事件在读取blob时触发</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * 方法</span></span><br><span class="line"><span class="comment"> *      FeileReader.abort()</span></span><br><span class="line"><span class="comment"> *          中止读取操作。在返回时，readyState属性为DONE。</span></span><br><span class="line"><span class="comment"> *      FeileReader.readAsArrayBuffer()</span></span><br><span class="line"><span class="comment"> *          开始读取指定的Blob中的内容，一旦完成，result属性中保存的将是被读取文件的ArrayBuffer数据对象</span></span><br><span class="line"><span class="comment"> *      FileReader.readAsBinaryString()</span></span><br><span class="line"><span class="comment"> *          开始读取指定的Blob中的内容，一旦完成，result属性中将包含所读取文件的原始二进制数据</span></span><br><span class="line"><span class="comment"> *      FileReader.readAsDataURL()</span></span><br><span class="line"><span class="comment"> *          开始读取指定的Blob中的内容，一旦完成，result属性中将包含一个data: URL格式的Base64字符串表示所读取文件的内容</span></span><br><span class="line"><span class="comment"> *          1. readAsDataURL </span></span><br><span class="line"><span class="comment"> *          方法会读取指定的 Blob 或 File 对象。读取操作完成的时候，readyState 会变成已完成DONE，并触发 loadend 事件，</span></span><br><span class="line"><span class="comment"> *          同时 result 属性将包含一个data:URL格式的字符串（base64编码）以表示所读取文件的内容。</span></span><br><span class="line"><span class="comment"> *          参数: 即将被读取的 Blob 或 File 对象。</span></span><br><span class="line"><span class="comment"> *      FileReader.readAsText() </span></span><br><span class="line"><span class="comment"> *          开始读取指定的Blob中的内容，一旦完成，result属性中将包含一个字符串来表示读取的文件内容</span></span><br><span class="line"><span class="comment"> *  </span></span><br><span class="line"><span class="comment"> * **/</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> input = <span class="built_in">document</span>.getElementById(<span class="string">"fielinput"</span>);</span><br><span class="line">input.addEventListener(<span class="string">'change'</span>, readFile, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">readFile</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">let</span> file = <span class="keyword">this</span>.files[<span class="number">0</span>];</span><br><span class="line">    <span class="comment">//判断是否是图片类型</span></span><br><span class="line">    <span class="comment">/*if (!/image\/\w+/.test(file.type)) &#123;</span></span><br><span class="line"><span class="comment">        alert("只能选择图片");</span></span><br><span class="line"><span class="comment">        return false;</span></span><br><span class="line"><span class="comment">        &#125;*/</span></span><br><span class="line">    <span class="keyword">let</span> reader = <span class="keyword">new</span> FileReader(); <span class="comment">// 返回一个新的FileReader函数</span></span><br><span class="line">    reader.readAsDataURL(file);</span><br><span class="line">    reader.onloadstart = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>)</span>&#123; </span><br><span class="line">        <span class="built_in">console</span>.log(e)</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">'开始了'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">    reader.onprogress = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(e)</span><br><span class="line">    &#125;</span><br><span class="line">    reader.onload = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(e);</span><br><span class="line">        <span class="built_in">console</span>.log(reader.result);</span><br><span class="line">        txshow.src = <span class="keyword">this</span>.result;</span><br><span class="line">        <span class="built_in">document</span>.getElementById(<span class="string">"data"</span>).innerText=<span class="keyword">this</span>.result.substring(<span class="keyword">this</span>.result.indexOf(<span class="string">','</span>)+<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    reader.onloadend = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(e)</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">'结束了'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>结果如下图所示:</p>
<p><img src="/2019/12/17/使用base64形式上传文件/base64.png" alt="base64图片"></p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2019/12/17/使用base64形式上传文件/">使用base64形式上传文件</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">张树淼</a></p>
        <p><span>发布时间:</span>2019-12-17, 10:17:47</p>
        <p><span>最后更新:</span>2019-12-17, 11:12:46</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2019/12/17/使用base64形式上传文件/" title="使用base64形式上传文件">http://yoursite.com/2019/12/17/使用base64形式上传文件/</a>
            <span class="copy-path" data-clipboard-text="原文: http://yoursite.com/2019/12/17/使用base64形式上传文件/　　作者: 张树淼" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/2019/12/05/页面显示隐藏visibilitychange事件/">
                    页面显示隐藏visibilitychange事件
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"使用base64形式上传文件　| Sapling　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
        <section class="youyan" id="comments">
    <script>
        var loadComment = function(){
            var d = document, s = d.createElement('script');
            s.src = 'http://v2.uyan.cc/code/uyan.js?uid=';
            (d.head || d.body).appendChild(s);
        }
    </script>
    
    <script> loadComment(); </script>

    <div id="uyan_frame"></div>
</section>
    




    <div class="scroll" id="post-nav-button">
        
            <a href="/" title="回到主页"><i class="fa fa-home"></i></a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/2019/12/05/页面显示隐藏visibilitychange事件/" title="下一篇: 页面显示隐藏visibilitychange事件">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2019/12/17/使用base64形式上传文件/">使用base64形式上传文件</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/12/05/页面显示隐藏visibilitychange事件/">页面显示隐藏visibilitychange事件</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/12/04/关于hexo的一些内容/">关于hexo的一些内容</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/12/04/hello-world/">Hello World</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/03/jQuery/">jQuery</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/09/29/跨域/">跨域</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/09/28/搭建HEXO个人博客/">如何搭建HEOX个人博客</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2016-2019 张树淼
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 1;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>